{% extends '::backend.html.twig' %}
{% block contenido %}

<a class="btn  btn-success" href="{{ path('catedra_new') }}">
    <i class="icon-plus" ></i>Agregar C&aacute;tedras
</a>
{% if entities %}
{% block documentReadyJavascript %} 
    {{ parent() }}{#este tiene el que oculta los alerts#}
<script type="text/javascript" >      
    $("#buttonFilter").click(function () {
        if ($("#divFilter").css('display') == 'none') {
                $("#divFilter").show("slow");
                $("#icono").attr("class", "icon-minus");
        } else {
            $("#divFilter").hide("slow");
            $("#icono").attr("class", "icon-plus");
        }
    });
    </script>
    <script type="text/javascript" >
        $(".delete").on('click', function(e){
                e.preventDefault()
                $this = $(this);
                $("#confirmation-dialog").dialog({
                resizable: false,
                height:180,
                width:'auto',
                modal: true,
                title:"Alerta!",
                buttons: {
                    "Eliminar": function() {
                        $this.parent().submit();
                    },
                    Cancelar: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
        </script>
{% endblock documentReadyJavascript %}
    {% include 'BackendBundle:Default:flashAlerts.html.twig'%}
        <fieldset>

             {%if filter%}
            <a id="buttonFilter" href="javascript:void(0)"> <legend><i id="icono" class="icon-minus"></i>Filtros</legend></a>
            <div id="divFilter" >
             {%else%}
                    <a id="buttonFilter" href="javascript:void(0)"> <legend><i id="icono" class="icon-plus"></i>Filtros</legend></a>
                    <div id="divFilter" style="display: none;">
            {%endif%}
                            <form id="searchCatedra" action="{{ path('catedra')}}" method="POST" >
            {{ form_widget(searchForm._token) }}       
                                    <table class="table table-bordered">
                                        <tr>    
                                            <td>Nombre</td>
                                            <td>{{ form_widget(searchForm.nombre) }}</td>
                                        </tr>
                                    </table>
                                    <input class="btn btn-info" type="submit" value="Filtrar">
                                    <a class="btn btn-inverse" href="{{ path('catedra')}}">Quitar Filtro</a>
                                </form>
                            </div>
                    </fieldset>
                    <legend>Cátedras</legend>
                    <table class="table table-striped table-bordered table-striped table-hover">

                        <thead>
                            <tr>                          
                                <th>Nombre</th>
                                <th>Opciones</th>
                            </tr>
                        </thead>
                        <tbody>
        {% for entity in entities %}
                                <tr class="{{ cycle(['GrillaRow','GrillaRowAlt'],loop.index) }}">
                                    <td>{{ entity.nombre }}</td>
                                    <td valign="middle" align="center">
                    {% include 'BackendBundle:Default:accionesConPermisos.html.twig' with {'basePath':'catedra','esEditor':true}%}  
                                            <a class="btn btn-ver btn-small" href="{{ path('catedra_getCargos', { 'id': entity.id }) }}">  <i class="icon-search"></i> Cargos</a>
                                            <a class="btn btn-ver btn-small" href="{{ path('catedra_getConcursos', { 'id': entity.id }) }}">  <i class="icon-search"></i> Concursos</a>
                                        </td>
                                    </tr>

                                    </tr>
        {% endfor %}
                                </tbody>
                            </table>
{% include 'BackendBundle:Default:paginador.html.twig' with { 'ruta': 'catedra' } only %}
                        </div>
                        <div id="confirmation-dialog" style="display:none">
                            <div class="alert alert-error">
                                <strong>Borrará!</strong>  la cátedra por completo, está seguro?
                            </div>
                        </div>
                {% else %}
                    <h3>{{ "No se encontraron catedras" }}</h3>
                {% endif %}
{% endblock %}
